package StringDemo;

import java.util.Scanner;

public class TelephoneNumberPinBi {
    public static void main(String[] args) {
        //键盘录入一个电话号码，并对号码的中间4位进行屏蔽*

        //1.键盘录入
        Scanner sc = new Scanner(System.in);

        String number;
        while (true){
            System.out.println("请输入号码：");
            number = sc.next();
            if (number.length() != 11){
                System.out.println("号码不符合规范，请重新输入：");
            }else {
                break;
            }
        }

        //2.截取号码前三、后四个字符
        //前三
        String start = number.substring(0,3);
        //后四
        String end = number.substring(7);

        //3.拼接
        String result = "";
        result = start + "****" + end;
        System.out.println(result);
    }
}
